import axios from 'axios'
import nprogress from 'nprogress'
import "nprogress/nprogress.css"
// 1:利用axios对象的方法create，创建一个axios示例
//2：request就是axios，需要稍微配置一些
const requests = axios.create({
    //配置对象
    baseURL: "/mock",
    timeout: 5000,
})
requests.interceptors.request.use((config) => {
    nprogress.start();
    return config

})
requests.interceptors.response.use((res) => {
    nprogress.done();
    return res.data;
}, (Error) => {
    return Promise.reject(new Error('faile'));

})
export default requests;